/*
 * *
 *  * <pre>
 *  *     author : ${USER}
 *  *     e-mail : xxx@xx
 *  *     time   : ${YEAR}/${MONTH}/${DAY}
 *  *     desc   :
 *  *     version: 1.0
 *  * </pre>
 *
 */
package com.ovopark.firecar.okhttp

import android.content.Context
import com.ovopark.firecar.R

public object RetrofitConstant {
    const val SUCCESS_MSG_OK = "ok" //登录-成功
    const val ERROR_MSG_DEVICE_OFFLINE = "DEVICE_OFFLINE" //设备离线
    const val ERROR_MSG_EXCEED_LIMIT = "EXCEED_LIMIT" //超出设备限制数
    const val ERROR_MSG_NO_DATA = "NO_DATA" //登录-无数据
    const val ERROR_MSG_NO_PHONE = "NO_PHONE" //登录-无电话
    const val ERROR_MSG_SEND_MESSAGES_BEYOND_LIMIT = "SEND_MESSAGES_BEYOND_LIMIT" //验证次数当天超过限制.

    //返回错误码.
    const val ERROR_RESPONSE_NULL = 1001 //接口返回为空.
    const val ERROR_RESPONSE_DATA_PARSE_EXCEPTION = 1002 // 数据解析错误,返回了錯誤的result .
    const val ERROR_RESPONSE_UNKNOWN = 1003 //未知返回结果
    const val ERROR_RESPONSE_TIMEOUT = 1004 //超时请求 .
    const val ERROR_CANCEL_REQUEST = 1005


    /**
     * 错误码转为对应的提示语.
     */
    public fun switchErrorMessage(context: Context, resultCode: String?): String? {
        val errorMessage: Int
        if (resultCode == null) {
            return context.getString(R.string.video_download_error_no_video)
        }
        errorMessage = when (resultCode) {
            "NO_VIDEO" -> R.string.video_download_error_no_video
            "START_REC_DOWN_SUCC" -> R.string.video_download_error_failed
            "START_REC_DOWN_FAIL" -> R.string.video_download_error_down_failed
            "START_REC_DOWN_IPC_NOT_EXIST" -> R.string.video_download_error_not_exist
            "START_REC_DOWN_IPC_IS_PALYING" -> R.string.video_download_error_ipc_playing
            "START_REC_DOWN_NOPLYER_ERR" -> R.string.video_download_error_noplayer
            "START_REC_DOWN_ERR_PER_LACK_CPU" -> R.string.video_download_error_per_lack_cpu
            "START_REC_DOWN_ERR_NVR_DOWNOPP_EXIST" -> R.string.video_download_error_down_exist
            "NVR_NO_DATA" -> R.string.video_download_error_no_data
            "NVR_EXCEPTION" -> R.string.video_download_error_nvr_exception
            "DEVICE_NOT_EXIST" -> R.string.video_download_error_device_not_exist
            "RESULT_INVALID_PARAMETER" -> R.string.video_download_error_invalid
            "PLATFORM_NOT_EXIST" -> R.string.video_download_error_platform_not_exist
            else -> R.string.video_download_error_no_video
        }
        return context.getString(errorMessage)
    }
}